<?php

require_once('config.php');

$id = $_GET["id"];

$sql = "SELECT * from userinfo WHERE id = '$id'";

$result = mysqli_query($conn, $sql);

$data = mysqli_fetch_array($result);

// echo json_encode($data);

// {
//   code: 1,
//   msg: '',
//   data: {
//     username: 1311,
//     password: 21211
//   }
// }

$obj = array();

if($data) {
  $obj["code"] = 1;
  $obj["data"]["username"] = $data['username'];
  $obj["data"]["password"] = $data['password'];
  $obj["data"]["telephone"] = $data['telephone'];
} else {
  $obj["code"] = 0;
  $obj["msg"] = '获取用户信息失败';
  $obj["data"] = false;
}

echo json_encode($obj);






